using AutoMapper;
using Joy.Erp.BasicArchives.Core;

namespace Joy.Erp.BasicArchives.Sales
{
    public class IntentOrderAutoMapperProfile : Profile
    {
        public IntentOrderAutoMapperProfile()
        {
            CreateMap<IntentOrder, IntentOrderDto>().MapExtraProperties().ReverseMap();
            CreateMap<IntentOrder, IntentOrderDocumentDto>().MapExtraProperties().ReverseMap();
            CreateMap<IntentOrder, IntentOrderCreateDto>().MapExtraProperties().ReverseMap();
            CreateMap<IntentOrder, IntentOrderUpdateDto>()
                .MapExtraProperties()
                .ForMember(dest => dest.Children, opt => opt.Ignore());
            CreateMap<IntentOrderUpdateDto, IntentOrder>()
                .MapExtraProperties()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.OrderType, opt => opt.Ignore())
                .ForMember(dest => dest.Operator, opt => opt.Ignore())
                .MapChildren<IntentOrderUpdateDto, IntentOrder, IntentOrderLineCreateOrUpdateDto, IntentOrderLine>();

            CreateMap<IntentOrderLine, IntentOrderLineDto>().MapExtraProperties().ReverseMap();
            CreateMap<IntentOrderLine, IntentOrderLineCreateOrUpdateDto>().MapExtraProperties().ReverseMap();
        }
    }
} 